﻿package core.ui.options
{
    import core.event.*;
    import core.ui.controls.*;
    import core.ui.util.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;

    public class GlowOptions extends Sprite
    {
        var p:Tuyitu;
        var filter:GlowFilter;
        public var opacity:Slidebar;
        public var hardness:Slidebar;
        public var size:Slidebar;
        public var color:ColorPad;

        public function GlowOptions(param1:Tuyitu, param2:GlowFilter)
        {
            this.p = param1;
            this.filter = param2;
            this.opacity = new Slidebar("rm_opacity", 0, 100, 100, Math.round(param2.alpha * 100), true);
            this.opacity.addEventListener(SliderEvent.DRAG, this.ValueChange);
            this.opacity.x = 80;
            this.opacity.y = 0;
            addChild(this.opacity);
            this.hardness = new Slidebar("rm_hardness", 0, 10, 100, param2.strength, true);
            this.hardness.addEventListener(SliderEvent.DRAG, this.ValueChange);
            this.hardness.x = 80;
            this.hardness.y = 25;
            addChild(this.hardness);
            this.size = new Slidebar("rm_size", 0, 100, 100, param2.blurX, true);
            this.size.addEventListener(SliderEvent.DRAG, this.ValueChange);
            this.size.x = 80;
            this.size.y = 50;
            addChild(this.size);
            this.color = new ColorPad(param2.color, true);
            this.color.addEventListener(MouseEvent.MOUSE_DOWN, this.ColorMouseDown);
            this.color.addEventListener(ColorPadEvent.CHOOSE_COLOR, this.ColorChange);
            this.color.x = 80;
            this.color.y = 80;
            addChild(this.color);
            var _loc_3:* = new Literal("rm_color");
            _loc_3.x = 80 - _loc_3.width - 2;
            _loc_3.y = 80;
            addChild(_loc_3);
            return;
        }// end function

        public function ColorMouseDown(event:MouseEvent) : void
        {
            new ColorPicker(this.p, event.target as ColorPad);
            return;
        }// end function

        public function ColorChange(event:ColorPadEvent) : void
        {
            this.filter.color = event.color;
            dispatchEvent(new ChangeEvent("update"));
            return;
        }// end function

        public function ValueChange(... args) : void
        {
            this.filter.alpha = this.opacity.value / 100;
            this.filter.strength = this.hardness.value;
            args = this.size.value;
            this.filter.blurY = args;
            this.filter.blurX = args;
            dispatchEvent(new ChangeEvent("update"));
            return;
        }// end function

    }
}
